﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace libLite.Forms
{
    public partial class addUser : Form
    {
        public addUser()
        {
            InitializeComponent();
        }

        public Bitmap Smanji(Bitmap b, int nWidth, int nHeight)
        {
            Bitmap result = new Bitmap(nWidth, nHeight);
            using (Graphics g = Graphics.FromImage((Image)result))
                g.DrawImage(b, 0, 0, nWidth, nHeight);
            return result;
        }


        private void slikaSaDiska_Click(object sender, EventArgs e)
        {
            OpenFileDialog otvoriSliku = new OpenFileDialog();
            if (otvoriSliku.ShowDialog() == DialogResult.OK)
            {
                slika.Image = (Image)Smanji((new Bitmap(otvoriSliku.FileName)), 143, 169);
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            slikaIzClipboarda_Click(sender, e);
        }

        private void slikaIzClipboarda_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsImage())
            {
                slika.Image = (Image)Smanji((Bitmap)Clipboard.GetImage(), 143, 169);
            }
            else
                MessageBox.Show("Clipboard ne sadrzi sliku!"); 
        }

        private void button3_Click(object sender, EventArgs e)
        {
            slikaSaDiska_Click(sender, e);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
